<?php
namespace app\admin\controller;
class Goodsagent extends Base
{
    //计算属性html
    public function lists(){
        if(is_post()){
            $d = $this->post;
            $map = [];
            if($d['shop_id']!='') $map[] = ['and','a.user_ext_id','=',$d['shop_id']];
            $w  = where($map);
            $rs = $this->db->query("
                select
                    b.*
                from
                    goods_agent a
                inner join
                    goods b on a.goods_id = b.id
                $w[0] order by a.id desc".limit($d['page'],$d['limit']), $w[1],'',true);
            $rule = [
                'status'=>function($v){return c("type.goods_status.$v");},
                'create_time' => 'com_time_format',
            ];
            $data = com_format($rs[0],$rule);
            if($rs){
                suc($data,$rs[1]);
            }else{
                suc([],0);
            }
        }

        $this->fetch(['shop_id'=>$this->get("id")],"/userext/agent");
    }
}
?>
